package com.wx.service.demo.service;

import android.os.IBinder;
import android.util.Log;

import java.lang.reflect.Method;

import wx.IWxManager;

public class WxServiceUtils {
    private static final String TAG = "WxServiceUtils";
    private static IWxManager wxManager = null;

    public static IWxManager getService() {
        if (wxManager != null) {
            return wxManager;
        }
        try {
            Class serviceManager = Class.forName("android.os.ServiceManager");
            Method method = serviceManager.getMethod("getService", String.class);
            IBinder binder = (IBinder) method.invoke(serviceManager, "wx.IWxManager");
            wxManager = IWxManager.Stub.asInterface(binder);
        } catch (Exception e) {
            Log.i(TAG, e.getLocalizedMessage());
        }
        return wxManager;
    }
}
